package com.demo.service;


import com.demo.common.BaseRes;
import com.demo.pojo.loginUser;
import com.demo.mapper.loginUserMapper;
import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;


@Slf4j
@Service
public class LoginUserService {

    @Resource
    private loginUserMapper loginMapper;


    public BaseRes login(loginUser login) {
        BaseRes res = new BaseRes();
        loginUser user = loginMapper.selectByloginUser(login.getUsername(),login.getPassword());

        if (user != null) {
            loginMapper.updateByPrimaryKey(login);
        } else {
            loginMapper.insertSelective(login);
        }
        res.setMsg("登录成功");
        return res;
    }
}